/*
	OPENASP MODULO NEWS VERSIONE 2.0
	AUTHOR: Becchetti Luca
*/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news]') AND type in (N'U'))
DROP TABLE [dbo].[tb_news]
;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_cat]') AND type in (N'U'))
DROP TABLE [dbo].[tb_news_cat]
;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_commenti]') AND type in (N'U'))
DROP TABLE [dbo].[tb_news_commenti]
;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_config]') AND type in (N'U'))
DROP TABLE [dbo].[tb_news_config]
;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_mod]') AND type in (N'U'))
DROP TABLE [dbo].[tb_news_mod]
;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_rank]') AND type in (N'U'))
DROP TABLE [dbo].[tb_news_rank]
;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_topic]') AND type in (N'U'))
DROP TABLE [dbo].[tb_news_topic]
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_news](
	[IDnews] [int] IDENTITY(1,1) NOT NULL,
	[Titolo] [varchar](50) NULL,
	[News] [text] NULL,
	[Ante] [text] NULL,
	[IDcate;ria] [int] NULL,
	[IDtopic] [int] NULL,
	[Stato] [int] NULL,
	[Autore] [int] NULL,
	[Prior_] [int] NULL,
	[Visite] [int] NULL,
	[Data] [varchar](50) NULL,
	[Datapub] [varchar](50) NULL,
	[Lingua] [varchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[IDnews] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_cat]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_news_cat](
	[IDcate;ria] [int] IDENTITY(1,1) NOT NULL,
	[NomeCat] [varchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[IDcate;ria] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_commenti]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_news_commenti](
	[IDcom] [int] IDENTITY(1,1) NOT NULL,
	[IDnews] [int] NULL,
	[Commento] [varchar](255) NULL,
	[Autore] [int] NULL,
	[Data] [varchar](50) NULL,
	[Tipo] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[IDcom] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_config]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_news_config](
	[NEWS_HOME] [int] NULL,
	[NEWS_DESC_MAX] [int] NULL,
	[NEWS_COMM_MAX] [int] NULL,
	[NEWS_TOT_PAGE] [int] NULL,
	[NEWS_ALL_LING] [varchar](50) NULL
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_mod]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_news_mod](
	[IDutente] [int] NOT NULL,
	[IDcateg] [int] NOT NULL
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_rank]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_news_rank](
	[Voto] [int] NULL,
	[IDnews] [int] NULL,
	[Data] [varchar](50) NULL
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_news_topic]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_news_topic](
	[IDtopic] [int] IDENTITY(1,1) NOT NULL,
	[NomeTopic] [varchar](50) NULL,
	[URLimg] [varchar](255) NULL,
	[IDcate;ria] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[IDtopic] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
